//
//  GQJLaySubViewController.m
//  TotalDemo
//
//  Created by gujian on 16/8/8.
//  Copyright © 2016年 gujian. All rights reserved.
//

#import "GQJLaySubViewController.h"


@implementation GQJLaySubViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    GQJLayView *layView = [[GQJLayView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
    layView.backgroundColor = [UIColor randomColor];
    [self.view addSubview:layView];
    
    [layView testNeedsLayout];
    [layView testLayoutIfNeeded];
    [layView testNeedsDisplay];
}



@end

@interface GQJLayView()

@property (nonatomic, weak) UILabel *titleLbl;


@end

@implementation GQJLayView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
        [self addSubview:lbl];
    }
    
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    NSLog(@"%s",__func__);
}

- (void)drawRect:(CGRect)rect
{
    [super drawRect:rect];
    NSLog(@"%s",__func__);
}


- (void)testNeedsLayout
{
    [self setNeedsLayout];
}

- (void)testLayoutIfNeeded
{
    [self layoutIfNeeded];
}

- (void)testNeedsDisplay
{
    [self setNeedsDisplay];
}

@end